//
//  HZL_FindSceneCollectionViewCell.m
//  B_Project
//
//  Created by dllo on 15/11/27.
//  Copyright © 2015年 HZL. All rights reserved.
//

#import "HZL_FindSceneCollectionViewCell.h"
#import "UIImageView+WebCache.h"


@interface HZL_FindSceneCollectionViewCell ()
@property (nonatomic, retain) UIImageView *img;
@property (nonatomic, retain) UILabel *cat_name;
@end
@implementation HZL_FindSceneCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.img = [[UIImageView alloc] init];
        self.img.contentMode = UIViewContentModeScaleAspectFill;
        self.img.clipsToBounds = YES;
//        self.img.backgroundColor = [UIColor blueColor];
        [self.contentView addSubview:self.img];
        
    
        self.cat_name = [[UILabel alloc] init];
//        self.cat_name.backgroundColor = [UIColor redColor];
        self.cat_name.textAlignment = NSTextAlignmentCenter;
        self.cat_name.font = [UIFont boldSystemFontOfSize:16];
        self.cat_name.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.cat_name];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.img.frame = CGRectMake(10, 10, self.contentView.frame.size.width - 10, self.contentView.frame.size.height - 20);
    self.cat_name.frame = CGRectMake(0 , (self.contentView.frame.size.width ) / 2 - 30, self.contentView.frame.size.width, 30);
}
- (void)setModel:(HZL_FindModel *)model
{
    if (_model != model) {
        _model = model;
    }
    self.cat_name.text = model.name;
    [self.img sd_setImageWithURL:[NSURL URLWithString:model.img]];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
